<?php
$enquire = $this->enquire;
?>
<div class="mainpage">
	<form>
    <div class="row-fluid">
        <div class="span4">
            <table class="table table-striped table-enquire" style="border:1px solid #ddd">
                <caption>Customer Information</caption>
                <tr>
                    <td>Full name</td>
                    <td><input class="input-v" type="text" value="<?php echo $enquire['full_name']; ?>" /></td>
                </tr>
                <tr>
                    <td>Email</td>
                    <td>
                        <input class="input-v" type="text" value="<?php echo $enquire['email']; ?>" />
                        <br/> <a href="mailto:<?php echo $enquire['email']; ?>" target="_blank"><b>Gửi email trả lời</b></a>
                    </td>
                </tr>
                <tr>
                    <td>Phone</td>
                    <td><input class="input-v" type="text" value="<?php echo $enquire['phone'] ?>" /></td>
                </tr>
                <tr>
                    <td>Country residence</td>
                    <td><input class="input-v" type="text" value="<?php echo $enquire['country_residence']; ?>" /></td>
                </tr>
                <tr>
                    <td>About</td>
                    <td>
                    	<?php
                    	function reference($rs) {
                            $labelEnquireReferenceType = new Apps_View_Helper_LabelEnquireReferenceType();
                        	return $labelEnquireReferenceType->labelEnquiresReferenceType($rs['reference_type']);
						}
						echo reference($enquire);

						function referenceElement($rs) {
						    $tbEnquire = new M_DbTable_Enquire();
						    $tbArticle = new M_DbTable_Article();

						    switch ($rs['reference_type']) {
						        case $tbEnquire::REFERENCE_TYPE_TOUR :
						            $article = $tbArticle->fetchRow(array('reference_id =?' => $rs['reference_id'], 'reference_type =?' => $tbArticle::REFERENCE_TYPE_TOUR));
						            $link    = '<a target="_blank" href="/tour/detail?id='. $rs['reference_id'] .'">'. $article['en_title'] .'</a>';
						            break;
						        case $tbEnquire::REFERENCE_TYPE_CRUISE :
						            $article = $tbArticle->fetchRow(array('reference_id =?' => $rs['reference_id'], 'reference_type =?' => $tbArticle::REFERENCE_TYPE_CRUISE));
						            $link    = '<a target="_blank" href="/cruise/detail?id='. $rs['reference_id'] .'">'. $article['en_title'] .'</a>';
						            break;
						        case $tbEnquire::REFERENCE_TYPE_HOTEL :
						            $article = $tbArticle->fetchRow(array('reference_id =?' => $rs['reference_id'], 'reference_type =?' => $tbArticle::REFERENCE_TYPE_HOTEL));
						            $link    = '<a target="_blank" href="/hotel/detail?id='. $rs['reference_id'] .'">'. $article['en_title'] .'</a>';
						            break;
						        case $tbEnquire::REFERENCE_TYPE_NOT_DEFINE :
						            $link = "";
						            break;
						    }
						    return $link;
						}
						echo '<br/><br/><b>'.referenceElement($enquire).'</b>';

                    	?>
                    </td>
                <tr>
                    <td>Status</td>
                    <td>
                    	<?php
                    	function status($rs) {
 			  				return ($rs['status'] == M_DbTable_Enquire::STATUS_ACTIVE)?
                                                '<a href="##" class="ajax-link popup hint must-confirm label label-success" data-ajax-to="/admin/enquire/change-value?p=status&id=' . $rs['id'] . '" data-must-confirm-msg="thay đổi ?" title="thay đổi" data-after-ajax="Checked">New</a>' :
                                                '<a href="##" class="ajax-link popup hint must-confirm label label-warning" data-ajax-to="/admin/enquire/change-value?p=status&id=' . $rs['id'] . '" data-must-confirm-msg="thay đổi ?" title="thay đổi" data-after-ajax="New">Checked</a>';
						}
						echo status($enquire);
                    	?>
                    </td>
                </tr>
            </table>
        </div>

        <div class="span8">
        	<span class="table-caption title">Subject and Content</span>
        	<input class="input-v input-xlager alert-info alert-block" type="text" value="<?php echo trim($enquire['subject']) ?>" />
        	<textarea rows="20" class="enquire-content"><?php echo $enquire['message'] ?></textarea>
        </div>
    </div>
    </form>
</div>
<style>
    .input-v {
    	-webkit-transition: none;
    	box-shadow: none;
    }
	.title {
		width : 100%;
		font-size: 13px;
		float: left;
	}
	.enquire-title {
		text-align: center;
		width : 100%;
		float: left;
	}
	.enquire-content {
		width : 100%;
		margin-top: 20px;
		float: left;
	}
	.input-xlager {
		width: 500px;
	}
</style>